package com.zzxy.po;

public class License {
}
    CREATE TABLE `t_license` (
        `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
        `license_key` VARCHAR(100) NOT NULL COMMENT '许可证密钥',
        `license_name` VARCHAR(100) NOT NULL COMMENT '许可证名称',
        `valid_from` DATETIME NOT NULL COMMENT '生效日期',
        `valid_to` DATETIME NOT NULL COMMENT '失效日期',
        `status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态：0-无效，1-有效',
        `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
        PRIMARY KEY (`id`),
        UNIQUE KEY `uk_license_key` (`license_key`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='许可证表';

        -- 插入一条测试数据
        INSERT INTO `t_license` (`license_key`, `license_name`, `valid_from`, `valid_to`, `status`)
        VALUES ('DEMO-LICENSE-123456', '演示许可证', '2023-01-01 00:00:00', '2024-12-31 23:59:59', 1);
        package com.example.ssm.entity;

        import java.io.Serializable;
        import java.util.Date;

public class License implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;
    private String licenseKey;
    private String licenseName;
    private Date validFrom;
    private Date validTo;
    private Integer status;
    private Date createdAt;
    private Date updatedAt;

    // Getters and Setters
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public String getLicenseKey() { return licenseKey; }
    public void setLicenseKey(String licenseKey) { this.licenseKey = licenseKey; }
    public String getLicenseName() { return licenseName; }
    public void setLicenseName(String licenseName) { this.licenseName = licenseName; }
    public Date getValidFrom() { return validFrom; }
    public void setValidFrom(Date validFrom) { this.validFrom = validFrom; }
    public Date getValidTo() { return validTo; }
    public void setValidTo(Date validTo) { this.validTo = validTo; }
    public Integer getStatus() { return status; }
    public void setStatus(Integer status) { this.status = status; }
    public Date getCreatedAt() { return createdAt; }
    public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; }
    public Date getUpdatedAt() { return updatedAt; }
    public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; }

    @Override
    public String toString() {
        return "License{" +
                "id=" + id +
                ", licenseKey='" + licenseKey + '\'' +
                ", licenseName='" + licenseName + '\'' +
                ", validFrom=" + validFrom +
                ", validTo=" + validTo +
                ", status=" + status +
                '}';
    }
}
package com.example.ssm.mapper;

        import com.example.ssm.entity.License;
        import org.apache.ibatis.annotations.Param;
        import org.springframework.stereotype.Repository;

@Repository
public interface LicenseMapper {

    /**
     * 根据许可证密钥查询许可证信息
     * @param licenseKey 许可证密钥
     * @return License对象
     */
    License selectByKey(@Param("licenseKey") String licenseKey);

    /**
     * 插入一条新的许可证记录
     * @param license 许可证信息
     * @return 受影响的行数
     */
    int insert(License license);

    /**
     * 更新许可证状态
     * @param licenseKey 许可证密钥
     * @param status 新状态
     * @return 受影响的行数
     */
    int updateStatus(@Param("licenseKey") String licenseKey, @Param("status") Integer status);
}